
export{
        getIcondata,
        getNewdata,
        formatkeyward,
    }
function getIcondata(data){
    const res=new Date()
    switch (data){
        case 'day':
            return res.getDate().toString().padStart(2,'0')
        case 'month':
            return (res.getMonth()+1).toString().padStart(2,'0')
        case 'year':
            return res.getFullYear().toString().substr(2)
    }
    
}

//获取当前日期
function getNewdata(field){
    const date = new Date()
    const year = date.getFullYear()
    const month =date.getMonth()+1
    const day =date.getDate()

    switch(field){
    
        case 'day':
            return `${year}-${month}-${day}`
        case 'month':
            return `${year}-${month}`
        case `year`:
            return `${year}`
    }

}
function formatkeyward(data){

    switch(data.length){
        case 8:{
            let year=data.substr(0,4)
            let month=Number(data.substr(4,2))
            let day=Number(data.substr(6,2))
            return `${year}-${month}-${day}`
        }
        case 6:{
            let year=data.substr(0,4)
            let month=Number(data.substr(4,2))
            return `${year}-${month}` }
        case 4:{
            let  year=data.substr(0,4)
         
           return `${year}`} 
    }
}